home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / rjs.lha / RJS / CmdLine / src / CmdOpt.C < prev    next >
C/C++ Source or Header  |  1991-06-14  |  1KB  |  66 lines

  1. #include "CmdLine.h"
  2.  
  3.  
  4. RJS_CmdOpt::RJS_CmdOpt(const char *k, CmdOptFlags f)
  5. {
  6.     key = k;
  7.     flags=f;
  8.     present=NotPresent;
  9.     val="";
  10. }
  11.  
  12. RJS_CmdOpt::RJS_CmdOpt(const char *k, const RJS_String &defval, CmdOptFlags f)
  13. {
  14.     key = k;
  15.     flags=f|Default|Value;
  16.     present=NotPresent;
  17.     val="";
  18.     dval=defval;
  19. }
  20.  
  21.  
  22. void RJS_CmdOpt::dump()
  23. {
  24.     cout << "RJS_CmdOpt: " << keyword() << " {" << value_type() << "} = '" << value() <<"'";
  25.     cout << " present_flags=(" ;
  26.     if (is_present()) {
  27.         cout << "Present";
  28.         if (is_default()) cout << ",DefaultValue";
  29.         if (value_present()) cout << ",ValuePresent";
  30.     } else cout << "NotPresent";
  31.     cout << ")\n";
  32. }
  33.  
  34. void RJS_CmdOpt::reset()
  35. {
  36.     present=NotPresent;
  37.     val="";
  38. }
  39.  
  40. void RJS_CmdOpt::set()
  41. {
  42.     present = RJS_CmdOpt::Present;
  43. }
  44.  
  45. int RJS_CmdOpt::set(const char *string_val)
  46. {
  47.     val=string_val;
  48.     present = RJS_CmdOpt::Present|RJS_CmdOpt::ValuePresent;
  49.     return set_value();
  50. }
  51.  
  52. int RJS_CmdOpt::set_default()
  53. {
  54.     val=dval;
  55.     present = RJS_CmdOpt::Present|RJS_CmdOpt::ValuePresent|DefaultValue;
  56.     return set_value();
  57. }
  58.  
  59. int RJS_CmdOpt::set_value() { return 1; }
  60.  
  61. const char *RJS_CmdOpt::value_type()
  62. {
  63.     return "string";
  64. }
  65.  
  66.